<?php

namespace app\admin\model\inventory;

use think\Model;

class KcSafeView extends Model
{
    // 表名
    protected $name = 'wms_kc_safe_view';

    protected $type = [
        'total_quantity'=>'quantity',
        'total_store_quantity'=>'quantity'
    ];
    
    protected $append = [
        'status_text'
    ];
    
    public function getStatusList()
    {
        //1正常，2超，3缺
        return ['1' => __('Status 1'),'2' => __('Status 2'), '3' => __('Status 3')];
    }
    
    public function getStatusTextAttr($value, $data)
    {
        $status_arr = $this->getStatusList();
        $status = 1;
        if($data['over_num']>0){
            $status = 2;
        }
        if($data['lack_num']<0){
            $status = 3;
        }
        return $status_arr[$status];
    }
}
